﻿using System;
using System.Xml;
using Autodesk.Revit.DB.Mechanical;

namespace YArchitech.HCLoad.Export
{
	internal class HcXmlZone : HcXmlElement
	{
		public HcXmlZone(Zone zone)
		{
			this.m_zone = zone;
		}

		public Zone Zone
		{
			get
			{
				return this.m_zone;
			}
		}

		public override bool WriteElementData(ref XmlElement xmlelem_zone)
		{
			bool result = base.WriteElementData(ref xmlelem_zone);
			XmlDocument ownerDocument = xmlelem_zone.OwnerDocument;
			xmlelem_zone.SetAttribute("id", this.Zone.Id.ToString());
			HcXmlElement.AppendTextElement(ref xmlelem_zone, "Name", this.Zone.Name);
			HcXmlElement.AppendTextElement(ref xmlelem_zone, "CADObjectId", this.Zone.Id.ToString());
			foreach (object obj in this.Zone.Spaces)
			{
				Space space = (Space)obj;
				XmlElement xmlElement = ownerDocument.CreateElement("SpaceId");
				xmlElement.SetAttribute("spaceIdRef", space.Id.ToString());
				xmlelem_zone.AppendChild(xmlElement);
			}
			return result;
		}

		private Zone m_zone;
	}
}
